<template>
  <div class="header-wrapper">
    <div class="header">
      <div class="headerleft">
        <i class="logo"></i>
        <h1 class="title" @click="goHome">北京市预约挂号统一平台</h1>
      </div>
      <div class="header-center">
        <label v-show="isShowSearch" class="search">
          <i class="icon"></i>
          <input
            type="text"
            name="search"
            v-model="searchValue"
            placeholder="点击输入医院名称"
            @focus="focusHandle"
            @blur="blurHandle"
            @input="changeInput()"
          />

          <button type="">搜索</button>
          <transition name="el-zoom-in-center">
            <div v-show="show" class="transition-box"></div>
          </transition>
        </label>
        <ul class="search-list" v-show="searchValue != ''">
          <li @click="listHandle(index)" v-for="(item, index) in searchList" :key="index">
            北京大学第一医院
          </li>
        </ul>
      </div>
      <div class="header-right">
        <span class="help-center">帮助中心</span>
        <span class="login" @click="handleOpen">{{
          $store.state.loginDate.userMobile == null ? "登录/注册" : $store.state.loginDate.userMobile.replace(/[0-9]{5}$/, "***")
        }}</span>
        <ul class="loginAfterList" v-show="$store.state.loginDate.userMobile != null">
          <li @click="backLogin">退出登录</li>
        </ul>
      </div>
    </div>
    <login></login>
  </div>
</template>
<script>
import login from "./Login/Login.vue";
export default {
  name: "v-header",
  components: {
    login,
  },
  data() {
    return {
      show: false,
      searchValue: "",
      isShowSearch: true,
      searchList: [
        "北京大学第一医院",
        "北京大学第一医院",
        "北京大学第一医院",
        "北京大学第一医院",
        "北京大学第一医院",
        "北京大学第一医院",
        "北京大学第一医院",
        "北京大学第一医院",
      ],
    };
  },

  methods: {
    goHome(){
      this.$router.push('/')
    },
    focusHandle() {
      this.show = true;
    },
    blurHandle() {
      this.show = false;
    },
    listHandle(index) {
      this.searchValue = "";
    },
    changeInput() {
      console.log(this.searchValue);
    },
    handleOpen() {
      if (this.$store.state.loginDate.userMobile === null) {
        this.$store.commit("loginHandleOpen");
      }
    },
    backLogin() {
      this.$store.commit("getUserMobile",null);
    },
  },
  created() {
    
  },
};
</script>

<style lang="scss">
.header-wrapper {
  width: 100%;
  height: 70px;
  box-shadow: 0 5px 10px #f5f5f5;
  background: #fff;
  box-sizing: border-box;
  .header {
    width: 1200px;
    margin: 0 auto;
    height: 70px;
    line-height: 70px;
    display: flex;
    .headerleft {
      flex: 0 0 320px;
      .logo {
        display: inline-block;
        width: 50px;
        height: 50px;
        background: url("../assets/helpcenter/logo.png") no-repeat;
        background-size: cover;
        vertical-align: middle;
        margin: -5px 12px 0 0;
      }
      .title {
        cursor:pointer;
        display: inline-block;
        font-size: 23px;
        color: #4490f3;
      }
      .title:hover{
        color:#85b9ff;
      }
    }
    .header-center {
      flex: 1 0 auto;
      text-align: center;
      .search {
        display: inline-block;
        width: 500px;
        height: 45px;
        line-height: 45px;
        border-bottom: 1px solid #eeeeee;
        .icon {
          display: inline-block;
          width: 20px;
          height: 20px;
          margin-right: 10px;
          background: url("../assets/helpcenter/fangda.png") no-repeat center;
          vertical-align: middle;
        }
        input {
          border: none;
          width: 400px;
        }
        button {
          border: none;
          background: none;
          color: #4490f3;
          font-weight: bold;
          font-size: 14px;
          cursor: pointer;
        }
        button:hover {
          color: #71adff;
        }
        .transition-box {
          width: 100%;
          height: 1px;
          background-color: #4a90f1;
          box-sizing: border-box;
        }
        /deep/.el-zoom-in-center-enter-active,
        .el-zoom-in-center-leave-active {
          transition: all 0.3s ease-out;
        }
        /deep/.el-zoom-in-center-enter,
        .el-zoom-in-center-leave-active {
          opacity: 1;
          transform: scaleX(0);
        }
      }
      .search-list {
        box-sizing: border-box;
        margin: -11px auto 0;
        width: 500px;
        min-height: 110px;
        height: 270px;
        overflow: auto;
        font-size: 13px;
        color: #606266;
        cursor: pointer;
        line-height: 35px;
        text-align: left;
        text-indent: 2em;
        background: #fff;
        box-sizing: border-box;
        box-shadow: 0 0 10px #ccc;
        li:hover {
          background: #f5f7fa;
        }
      }
      .search-list::-webkit-scrollbar {
        width: 6px;
      }
      .search-list::-webkit-scrollbar-track-piece {
        background: #fff;
      }
      .search-list::-webkit-scrollbar-thumb {
        border-radius: 3px;
        -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
        background: rgba(0, 0, 0, 0.1);
      }
      .search-list::-webkit-scrollbar-track {
        -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
        border-radius: 0;
        background: rgba(0, 0, 0, 0.2);
      }
    }

    .header-right {
      flex: 0 0 200px;
      font-size: 14px;
      color: #666666;
      position: relative;
      span {
        padding: 0 20px;
        cursor: pointer;
      }
      span:hover {
        color: #71adff;
      }
      .login {
        display: inline-block;
        width: 60px;
        font-weight: bold;
      }
      .loginAfterList {
        display:none;
        line-height: 20px;
        cursor: pointer;
        position: absolute;
        right: 20px;
        bottom: -10px;
        background: #fff;
        li:hover {
          color: #71adff;
        }
      }
      
    }
    .header-right:hover .loginAfterList{
      display:block;
    }
  }
}
</style>
